package com.example.ck.controller;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.example.ck.entity.Auditproject;
import com.example.ck.entity.Contract;
import com.example.ck.entity.User;
import com.example.ck.service.*;
import com.example.ck.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 合同表(Contract)表控制层
 *
 * @author makejava
 * @since 2024-05-15 10:07:07
 */
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("contract")
public class ContractController {
    @Autowired
    private ContractService contractService;

    /**
     * 招标商添加合同
     */

    @PostMapping("/addContract")
    public ResultVo addContract(@RequestBody Contract contract) {
        boolean b = contractService.addHt(contract);
        ResultVo rv = new ResultVo<>();
        if (b) {
            return new ResultVo("合同上传成功", true, null);
        } else {
            return new ResultVo("合同上传失败", false, null);
        }
    }

    /**
     * 根据项目id查询合同
     */

    @GetMapping("/selectContractByPid")
    public ResultVo selectContractByPid(Integer projetcId) {
        Contract htByXmId = contractService.getHtByXmId(projetcId);
        return new ResultVo("查询成功", true, htByXmId);
    }
}

